package org.ttitfly.ttcore.web.menu;

import java.util.ArrayList;
import java.util.List;

import org.ttitfly.ttcore.entity.menu.Menu;
import org.ttitfly.ttcore.entity.menu.MenuItem;
import org.ttitfly.ttcore.web.CrudActionSupport;

import com.google.gson.Gson;

public class MenuAction extends CrudActionSupport<Menu>  {
	
	@Override
	public String execute() throws Exception {
		
		MenuItem child1 = new MenuItem();
		child1.setCls("file1");
		child1.setId(11L);
		child1.setLeaf(true);
		child1.setChecked(false);
		child1.setChildren(null);
		child1.setText("S600");
		
		MenuItem child2 = new MenuItem();
		child2.setCls("file1");
		child2.setId(12L);
		child2.setLeaf(true);
		child2.setChecked(false);
		child2.setChildren(null);
		child2.setText("slK200");
		
		List<MenuItem> list = new ArrayList<MenuItem>();
		list.add(child1);
		list.add(child2);
		MenuItem parent = new MenuItem();
		parent.setCls("folderr1");
		parent.setId(9L);
		parent.setLeaf(false);
		parent.setChecked(false);
		parent.setChildren(list);
		parent.setText("Benz");
		
		
		List<MenuItem> result = new ArrayList<MenuItem>();
		result.add(parent);
		Gson gson = new Gson();
		
		String json = gson.toJson(result);
		printJson(json);
		
		return null;
	}

	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String list() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void prepareModel() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Menu getModel() {
		// TODO Auto-generated method stub
		return null;
	}

}
